﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RecuperatePlanSumirise.aspx.cs"
    Inherits="GH.Web.Welfare.RecuperatePlan" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>欢迎使用工会管理系统</title>
    <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            font-size: 16px;
            font-weight: bold;
        }
    </style>
    <style type='text/css'>
        thead
        {
            font-size: 12pt;
            font-weight: bold;
            color: #444;
        }
        tbody
        {
            font-size: 10pt;
            color: #444;
        }
        td, th
        {
            border: solid 1px #E6E6E6;
            padding-left: 3px;
        }
        th
        {
            background-color: #5B8;
        }
        .alternation
        {
            background-color: #D2FFD2;
        }
        .alternation3
        {
            background-color: #DDEEDD;
        }
        .selected
        {
            background-color: #B3E1A3;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="../css/css.css" />
    <link rel="stylesheet" type="text/css" href="/css/jquery-ui-1.7.2.custom.css" />
    <link rel="stylesheet" type="text/css" href="../JqueryUI/themes/ui-lightness/jquery-ui-1.7.2.custom.css" />
    <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../css/calendar.css" />

    <script type="text/javascript" src="../javascript/jquery-1.3.2.js"></script>

    <script type="text/javascript" src="../javascript/jquery-ui-1.7.2.custom.js"></script>

    <script type="text/javascript" src="../javascript/messageBox.js"></script>

    <script type="text/javascript" src="../javascript/formValidator.js"></script>

    <script type="text/javascript" src="../javascript/formValidatorRegex.js"></script>

    <script type="text/javascript" src="../javascript/Public.js"></script>

    <script type="text/javascript" src="../javascript/jquery-calendar.js"></script>

    <script type="text/javascript" src="../javascript/cal.js"></script>

    <!-- BEGIN  Select带可输入的功能  BEGIN -->

    <script type='text/javascript'>
        //定义 select 原值
        var oldValue, oldText;
        //select下拉框的onkeydown事件，修改下拉框的值
        function catch_keydown(sel) {
            switch (event.keyCode) {
                case 13: //回车键
                    event.returnValue = false;
                    break;
                case 27: //Esc键
                    sel.options[sel.selectedIndex].text = oldText;
                    sel.options[sel.selectedIndex].value = oldValue;
                    event.returnValue = false;
                    break;
                case 8:  //空格健
                    var s = sel.options[sel.selectedIndex].text;
                    s = s.substr(0, s.length - 1);
                    if (sel.options[0].value == sel.options[sel.selectedIndex].text) {
                        sel.options[sel.selectedIndex].value = s;
                        sel.options[sel.selectedIndex].text = s;
                    }
                    event.returnValue = false;
                    break;
            }
            if (!event.returnValue && sel.onchange)
                sel.onchange(sel)
        }

        //select下拉框的onkeypress事件，修改下拉框的值
        function catch_press(sel) {
            if (sel.selectedIndex == 0) {
                var s = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode);
                sel.options[sel.selectedIndex].value = s;
                sel.options[sel.selectedIndex].text = s;
                event.returnValue = false;
                if (!event.returnValue && sel.onchange)
                    sel.onchange(sel)
            }
        }

        //select下拉框的onfocus事件，保存下拉框原来的值
        function catch_focus(sel) {
            oldText = sel.options[sel.selectedIndex].value;
            oldValue = sel.options[sel.selectedIndex].value;
        }  
    </script>

    <!-- END    Select带可输入的功能  END-->
    <!-- BEGIN  画面的控制  BEGIN -->

    <script type='text/javascript'>
        $(document).ready(function() {


            /////////////////////////////////////////////////画面初始化//////////////////////////////////////////////
            //初始化数据

            // GetOrganizationSumirise("SELECT");
            //初始化权限
            //SetInitialRights();
            InitData();
            /////////////////////////////////////////////////画面初始化//////////////////////////////////////////////

            /////////////////////////////////////////////////画面共通方法//////////////////////////////////////////////
            //权限设定
            function SetInitialRights() {
                //汇总权限
                if ($('#hddRights').val() != "1") {
                    $("#btnSummarys").css({ "display": "none" });

                }
                //查看其它单位权限
                if ($('#hddOpen').val() != "1") {
                    $("#btnOpen").css({ "display": "none" });

                }



            }
            //追加行常量
            function SetRowValue(strValue1, strValue2, strValue3, strValue4, strValue5, strValue6, strValue7, strValue8, strValue9) {
                var strRowAdd = "<tr><td align='center'>a1</td><td align='center'>a2</td><td align='center'>a3</td><td align='center'>a4</td><td align='center'>a5</td><td align='center'>a6</td><td align='center'>a7</td><td align='center'>a8</td><td style='display:none'>a9</td></tr>";
                return strRowAdd.replace("a1", strValue1).replace("a2", strValue2).replace("a3", strValue3).replace("a4", strValue4).replace("a5", strValue5).replace("a6", strValue6).replace("a7", strValue7).replace("a8", strValue8).replace("a9", strValue9);
            }


            //追加行数据
            function SetAddRowDataValue(RowNo) {
                var strRemark = " ";
                var UninonId = $("#hddUnionID").val();
                //                return SetRowValue(RowNo,"",SetSelectValue(GetVipMemberList(UninonId), ""), SetDisEditSelectValue(GetSexList()), SetInputDefaultValue("", 2), SetSelectValue(GetVipMemberList(UninonId), ""), SetSelectValue(GetVipMemberList(UninonId), ""), SetSelectValue(GetVipMemberList(UninonId), ""), SetInputDefaultValue("", 10), SetInputDefaultValue("", 30));
                return SetRowValue(
                RowNo, //序号
                $("#lblUnion").text(), //单位名称
               "0", //享受人数
                SetInputDefaultValue("", 10), //计划人数1
                SetInputDefaultValue("", 10), //计划人数2
                SetInputDefaultValue("", 10), //计划人数3
                SetInputDefaultValue("", 10), //计划人数4
                SetInputDefaultValue("", 10),
                UninonId); //计划人数5
            }


            //对应业务信息
            function GetOrganizationSumirise(RightsFlg, theDate) {
                //清空明细显示
                $("#example>tbody>tr").each(function(i, item) {
                    if (i > 0) {
                        $(this).remove();
                    }
                });
                if ($("#hddRights").val() == "1") {
                    RightsFlg = "Summary";
                    $('#hddSumarry').val("1");
                } else {
                    RightsFlg = "SELECT";
                    $('#hddSumarry').val("0");
                }
                //明细赋值
                var strStrHtml = "";
                var queryString = "time=" + new Date() + "&TransFlg=RecuperatePlan" + "&RightsFlg=" + RightsFlg + "&theDate=" + theDate;
                $.ajax
                    ({
                        async: false,
                        type: "post", //ajax请求方式
                        url: "../ajaxGetJason.aspx", //请求服务器地址
                        datatype: "json", //希望数据库返回的数据类型
                        data: queryString, //发送给服务器的数据
                        processData: false, //阻止数据被自动转换为url编码
                        success: function(data) {//请求成功则调用该函数
                            var temp = eval(data);
                            if (temp) {
                                var theTotal = 0; //总合计
                                var jh1Total = 0; //计划人数1
                                var jh2Total = 0; //计划人数2
                                var jh3Total = 0; //计划人数4
                                var jh4Total = 0; //计划人数4
                                var jh5Total = 0; //计划人数5
                                $.each(temp, function(i, item) {

                                    var total = 0;
                                    if ((item["计划人数1"]) != "") {
                                        total += parseInt(item["计划人数1"]);
                                        jh1Total += parseInt(item["计划人数1"]);
                                    }
                                    if ((item["计划人数2"]) != "") {
                                        total += parseInt(item["计划人数2"]);
                                        jh2Total += parseInt(item["计划人数2"]);
                                    }
                                    if ((item["计划人数3"]) != "") {
                                        total += parseInt(item["计划人数3"]);
                                        jh3Total += parseInt(item["计划人数3"]);
                                    }
                                    if ((item["计划人数4"]) != "") {
                                        total += parseInt(item["计划人数4"]);
                                        jh4Total += parseInt(item["计划人数4"]);
                                    }
                                    if ((item["计划人数5"]) != "") {
                                        total += parseInt(item["计划人数5"]);
                                        jh5Total += parseInt(item["计划人数5"]);
                                    }
                                    theTotal += total;
                                    if (total == 0) {
                                        total = "";
                                    }

                                    var strTr = "<tr style='height: 22px;'><td align='center'>" + (i + 1)
                                             + "</td><td align='center'>" + item["单位名称"]
                                              + "</td><td align='center'>" + total
                                              + "</td><td align='center'>" + item["计划人数1"]
                                              + "</td><td align='center'>" + item["计划人数2"]
                                              + "</td><td align='center'>" + item["计划人数3"]
                                              + "</td><td align='center'>" + item["计划人数4"]
                                              + "</td><td align='center'>" + item["计划人数5"]
                                              + "</td><td style='display:none'>" + item["单位"]
                                              + "</td></tr> "

                                    strStrHtml += strTr;
                                });
                                if (RightsFlg == "Summary") {
                                    var thestrTr = "<tr style='height: 22px;'><td align='center'>" + ""
                                             + "</td><td align='center'>" + "合计"
                                              + "</td><td align='center'>" + theTotal
                                              + "</td><td align='center'>" + jh1Total
                                              + "</td><td align='center'>" + jh2Total
                                              + "</td><td align='center'>" + jh3Total
                                              + "</td><td align='center'>" + jh4Total
                                              + "</td><td align='center'>" + jh5Total
                                              + "</td><td style='display:none'>" + item["单位"]
                                              + "</td></tr> "
                                    strStrHtml += thestrTr;
                                }
                                $("#example").append(strStrHtml);
                            }
                        }
                    });
            }


            function AddRowEvent(intRowNo) {

                //                //参加工作时间
                //                $("#example>tbody>tr:eq(" + intRowNo + ")").find("td:eq(3)").find('input').simpleDatepicker({ startdate: 1920, enddate: 2050 });

                //                //疗养时间
                //                $("#example>tbody>tr:eq(" + intRowNo + ")").find("td:eq(5)").find('input').simpleDatepicker({ startdate: 1920, enddate: 2050 });


            }
            /////////////////////////////////////////////////画面共通方法//////////////////////////////////////////////
            function InitData() {
                var queryString = "";
                var theDate = $("#hddYear").val();
                var UnionID = $("#hddUnionID").val();

                var UpdateFlg = btnName; //操作区分，更新或者新规
                var FormFlg = "RecuperatePlan"; //处理画面区分，对应不同的后台业务处理
                queryString = "FormFlg=" + FormFlg
                                + "&UpdateFlg=" + UpdateFlg
                                + "&UnionID=" + UnionID//单位编号
                                + "&strName=" + theDate//年份
                                 + "&id=" + ""//无用


                $.ajax
                        ({
                            async: false,
                            type: "post", //ajax请求方式
                            url: "../AjaxExist.aspx", //请求服务器地址
                            datatype: "json", //希望数据库返回的数据类型
                            data: queryString, //发送给服务器的数据
                            processData: false, //阻止数据被自动转换为url编码
                            success: function(data) {//请求成功则调用该函数
                                if (data == "0") {
                                    var beginTime = parseInt(data);

                                    //清空明细显示
                                    $("#example>tbody>tr").each(function(i, item) {
                                        if (i > 0) {
                                            $(this).remove();
                                        }
                                    });

                                }
                                else {
                                    var beginTime = parseInt(data);
                                    $("#spBegin").text(beginTime);
                                    $("#spEnd").text((beginTime + 4));

                                    GetOrganizationSumirise("SELECT", beginTime)

                                    var beginYear = $("#spBegin").text();
                                    $("#Span1").text(parseInt(beginYear));
                                    $("#Span2").text(parseInt(beginYear) + 1);
                                    $("#Span3").text(parseInt(beginYear) + 2);
                                    $("#Span4").text(parseInt(beginYear) + 3);
                                    $("#Span5").text(parseInt(beginYear) + 4);
                                    var queryString = "";
                                    var FormFlg = "SelectCurrentYear"; //处理画面区分，对应不同的后台业务处理
                                    queryString = "FormFlg=" + FormFlg
                                    + "&UpdateFlg=" + "Update"
                                    + "&Id=" + beginTime;
                                    $(this).dialog('close');
                                    $.ajax
                                    ({
                                        async: false,
                                        type: "post", //ajax请求方式
                                        url: "../ajaxUpdate.aspx", //请求服务器地址
                                        datatype: "json", //希望数据库返回的数据类型
                                        data: queryString, //发送给服务器的数据
                                        processData: false, //阻止数据被自动转换为url编码
                                        success: function(data) {//请求成功则调用该函数
                                            if (data == "OK") {
                                                window.close();
                                            } else {
                                                window.close();
                                            }
                                        }
                                    });
                                }
                            }
                        });


            }

            //处理区分
            var btnName = "";
            function createQueryString() {
                var queryString = "";
                var theDate = $("#txtDate").val();
                var UnionID = $("#hddUnionID").val();

                var UpdateFlg = btnName; //操作区分，更新或者新规
                var FormFlg = "RecuperatePlan"; //处理画面区分，对应不同的后台业务处理
                queryString = "FormFlg=" + FormFlg
                                + "&UpdateFlg=" + UpdateFlg
                                + "&UnionID=" + UnionID//单位编号
                                + "&strName=" + theDate//年份
                                 + "&id=" + ""//无用

                return queryString;
            }

            function Update(operflg) {
                var addValid = false; //插入操作是否成功flg
                var beginTime = 0;
                $.ajax
                        ({
                            async: false,
                            type: "post", //ajax请求方式
                            url: "../AjaxExist.aspx", //请求服务器地址
                            datatype: "json", //希望数据库返回的数据类型
                            data: createQueryString(), //发送给服务器的数据
                            processData: false, //阻止数据被自动转换为url编码
                            success: function(data) {//请求成功则调用该函数
                                if (data == "0") {
                                    beginTime = parseInt($("#txtDate").val());
                                    $("#spBegin").text(beginTime);
                                    $("#spEnd").text((beginTime + 4));

                                    GetOrganizationSumirise("SELECT", beginTime)
                                }
                                else {
                                    //                                    beginTime = parseInt(data);
                                    //                                    $("#spBegin").text(beginTime);
                                    //                                    $("#spEnd").text((beginTime + 4));

                                    //                                    GetOrganizationSumirise("SELECT", beginTime)
                                    var beginTime = parseInt(data);
                                    $("#spBegin").text(beginTime);
                                    $("#spEnd").text((beginTime + 4));

                                    var UnionID = $("#hddUnionID").val();



                                    GetOrganizationSumirise("SELECT", beginTime)

                                }
                            }
                        });
                var beginYear = $("#spBegin").text();
                $("#Span1").text(parseInt(beginYear));
                $("#Span2").text(parseInt(beginYear) + 1);
                $("#Span3").text(parseInt(beginYear) + 2);
                $("#Span4").text(parseInt(beginYear) + 3);
                $("#Span5").text(parseInt(beginYear) + 4);
                return addValid;
            };
            /////////////////////////////////////////////////画面事件//////////////////////////////////////////////
            //追加鼠标事件 行选择
            $('tbody > tr', $('#example')).live("click", function() {
                $('.selected').removeClass('selected');
                $(this).addClass('selected'); //this 表示引发事件的对象，但它不是 jquery 对象
                var tr_id = $(this).find("td:eq(0)").text();
                //对隐藏控件设定当前行的值
                $('#txtRowNo').val(tr_id);
            }).hover(		//注意这里的链式调用
					        function() {
					            $(this).addClass('mouseOver');
					        },
			        function() {
			            $(this).removeClass('mouseOver');
			        }
           );
            //行删除
            $('#btnDelete').click(function() {
                if ($.trim($('#txtRowNo').val()) == "") {
                    alert("请选择行");
                    return;
                }
                if (!window.confirm("请确认是否删除记录。 ")) {
                    return;
                }
                var rows = $('#txtRowNo').val();

                var theID = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(8)").text();
                var theDate = $("#spBegin").text();

                var theDeleteString = "ID=" + theID //ID编号
                                       + "&theDate=" + theDate
                                       + "&UpdateFlg=" + "Update"
                                       + "&FormFlg=" + "RecuperatePlan";


                $.ajax
                    ({
                        async: false,
                        type: "post", //ajax请求方式
                        url: "../AjaxDelete.aspx", //请求服务器地址
                        datatype: "json", //希望数据库返回的数据类型
                        data: theDeleteString, //发送给服务器的数据
                        processData: false, //阻止数据被自动转换为url编码
                        success: function(data) {//请求成功则调用该函数
                            if (data == "OK") {
                                //                                $('#txtRowNo').val("");
                                //                                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(2)").empty();
                                //                                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(3)").empty();
                                //                                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(4)").empty();
                                //                                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(5)").empty();
                                //                                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(6)").empty();
                                //                                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(7)").empty();
                                //                                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(8)").empty();
                                GetOrganizationSumirise("SELECT", $("#spBegin").text());
                            }
                            else {
                                alert("删除失败！")
                            }
                        }
                    });
            });

            //插入行
            $('#btnAdd').click(function() {


                var tr_id = $("#example>tbody>tr:last").find("td:eq(0)").text();
                if ($.trim(tr_id) == "序号" || $.trim(tr_id) == "") {
                    tr_id = 0;
                }
                var id = parseInt(tr_id) + 1;
                $("#example").append(SetAddRowDataValue(id));

                AddRowEvent(id); //添加事件
            });


            //插入行
            $('#btnNew').click(function() {
                btnName = "Add";

                $("#datepanle").dialog('open');
            });

            //行编辑
            $('#btnEdit').click(function() {
                if ($.trim($('#txtRowNo').val()) == "") {
                    alert("请选择行");
                    return;
                }
                var rows = $('#txtRowNo').val();
                //序号
                //单位


                //参加工作时间
                editedContent3 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(3)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(3)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(3)").append(SetInputDefaultValue(editedContent3, 10));

                //享受标准
                editedContent4 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(4)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(4)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(4)").append(SetInputDefaultValue(editedContent4, 10));

                //疗养时间
                editedContent5 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(5)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(5)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(5)").append(SetInputDefaultValue(editedContent5, 10));

                //备注
                editedContent6 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(6)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(6)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(6)").append(SetInputDefaultValue(editedContent6, 10));

                //疗养时间
                editedContent5 = $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(7)").text();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(7)").empty();
                $("#example>tbody>tr:eq(" + rows + ")").find("td:eq(7)").append(SetInputDefaultValue(editedContent5, 10));


                //添加事件
                AddRowEvent(rows);
                editedID = rows;
            });

            /// <summary>
            /// <p><b>方法名：</b>CreateUpdateString</p>
            /// <p><b>概要説明:</b>ajax向后台传的参数，区分ID和子区分ID</p>
            /// <p><b>作者  :</b>程明亮</p>
            /// <p><b>日期  :</b>2009/07/24</p>
            /// <p><b>修正履历:</b></p>
            /// </summary>
            function CreateUpdateString() {
                var no = "";
                //单位

                var unionID = "";
                //姓名
                var vipName = "";

                //年份
                var theYear = $("#spBegin").text();

                //计划人数1
                var count1 = "";

                //计划人数
                var count2 = "";

                //计划人数3
                var count3 = "";

                //计划人数4
                var count4 = "";

                //计划人数5
                var count5 = "";


                $("#example").find("tr:not(:eq(0))").each(function() {

                    if ($(this).find('td:eq(3)').find('input').length > 0) {
                        //计划人数1
                        if ($(this).find('td:eq(3)').find('input').length > 0) {
                            count1 = count1 + $(this).find('td:eq(3)').find('input').val() + ",";
                        }
                        else {
                            count1 = count1 + $(this).find('td:eq(3)').text() + ",";
                        }

                        //计划人数2
                        if ($(this).find('td:eq(4)').find('input').length > 0) {
                            count2 = count2 + $(this).find('td:eq(4)').find('input').val() + ",";
                        }
                        else {
                            count2 = count2 + $(this).find('td:eq(4)').text() + ",";
                        }

                        //计划人数3
                        if ($(this).find('td:eq(5)').find('input').length > 0) {
                            count3 = count3 + $(this).find('td:eq(5)').find('input').val() + ",";
                        }
                        else {
                            count3 = count3 + $(this).find('td:eq(5)').text() + ",";
                        }

                        //计划人数4
                        if ($(this).find('td:eq(6)').find('input').length > 0) {
                            count4 = count4 + $(this).find('td:eq(6)').find('input').val() + ",";
                        }
                        else {
                            count4 = count4 + $(this).find('td:eq(6)').text() + ",";
                        }

                        //计划人数5
                        if ($(this).find('td:eq(7)').find('input').length > 0) {
                            count5 = count5 + $(this).find('td:eq(7)').find('input').val() + ",";
                        }
                        else {
                            count5 = count5 + $(this).find('td:eq(7)').text() + ",";
                        }
                        unionID = unionID + $(this).find('td:eq(8)').text() + ",";
                    }


                })

                var queryString = "Union=" + unionID
                               + "&theYear=" + theYear
                               + "&count1=" + count1
                               + "&count2=" + count2
                               + "&count3=" + count3
                              + "&count4=" + count4
                              + "&count5=" + count5
                              + "&UpdateFlg=" + "Update"
                              + "&FormFlg=" + "RecuperatePlan";
                return queryString;
            };

            //提交画面所有数据
            $('#btnSave').click(function() {
                if ($("#example").find("tr").length == 1) {
                    alert("没有可保存的数据！");
                    return;
                }

                $.ajax
            ({
                async: false,
                type: "post", //ajax请求方式
                url: "../ajaxUpdate.aspx", //请求服务器地址
                datatype: "json", //希望数据库返回的数据类型
                data: CreateUpdateString(), //发送给服务器的数据
                processData: false, //阻止数据被自动转换为url编码
                success: function(data) {//请求成功则调用该函数
                    if (data == "OK") {
                        alert("更新成功！");
                        GetOrganizationSumirise("SELECT", $("#spBegin").text());
                        var beginYear = $("#spBegin").text();
                        $("#Span1").text(parseInt(beginYear));
                        $("#Span2").text(parseInt(beginYear) + 1);
                        $("#Span3").text(parseInt(beginYear) + 2);
                        $("#Span4").text(parseInt(beginYear) + 3);
                        $("#Span5").text(parseInt(beginYear) + 4);
                        //                        var submitForm = document.getElementById("mainForm");
                        //                        submitForm.submit();
                    }
                    else {
                        alert("更新失败！")
                    }
                }
            });

            });
            $("#datepanle").dialog({
                bgiframe: true,
                autoOpen: false,
                height: 150,
                modal: true,
                draggable: true,
                buttons: {
                    '提交': function() {

                        Update(btnName);
                        $("#hddSumarry").val("0")
                        var queryString = "";
                        var FormFlg = "SelectCurrentYear"; //处理画面区分，对应不同的后台业务处理
                        queryString = "FormFlg=" + FormFlg
                               + "&UpdateFlg=" + "Update"
                                + "&Id=" + $("#txtDate").val();
                        $(this).dialog('close');
                        $.ajax
                        ({
                            async: false,
                            type: "post", //ajax请求方式
                            url: "../ajaxUpdate.aspx", //请求服务器地址
                            datatype: "json", //希望数据库返回的数据类型
                            data: queryString, //发送给服务器的数据
                            processData: false, //阻止数据被自动转换为url编码
                            success: function(data) {//请求成功则调用该函数
                                if (data == "OK") {
                                    window.close();
                                } else {
                                    window.close();
                                }
                            }
                        });

                    },
                    '取消': function() {
                        $(this).dialog('close');
                    }
                },
                close: function() {
                    $("#txtDate").val("");
                }
            });

            //单位选择画面
            $('#btnOpen').click(function() {
                window.showModalDialog("RecuperatePlanDateDialog.aspx?Random=" + Math.random(), window, "dialogWidth:173px;dialogHeight:400px;status=no;help=no;scroll:no");
                var submitForm = document.getElementById("mainForm");
                submitForm.submit();
                //清空当前行号
                $('#txtRowNo').val("");
            });

            //汇总
            $('#btnSummarys').click(function() {
                GetOrganizationSumirise("Summary", $("#spBegin").text());
                //汇总区分
                $('#hddSumarry').val("1");
            });


            //打印
            $('#btnPrintView').click(function() {
                if ($("#example").find("tr").length == 1) {
                    alert("没有可打印的数据！");
                    return;
                }
                if ($('#hddSumarry').val() == "1") {
                    openwindow("RecuperatePlanSumirisePrint.aspx?Random=" + Math.random() + " &RightsFlg=" + "Summary", 'newwindow', 950, 600);
                }
                else {
                    openwindow("RecuperatePlanSumirisePrint.aspx?Random=" + Math.random() + " &RightsFlg=" + "SELECT", 'newwindow', 950, 600);
                }
            });

            $('#btnExcelExport').click(function() {
                if ($("#example").find("tr").length == 1) {
                    alert("没有可导出的数据！");
                    return;
                }
                if ($('#hddSumarry').val() == "1") {
                    window.open("../Common/ExcelExport.aspx?Random=" + Math.random() + "&TransFlg=RecuperatePlanSumirise" + "&Action=Summary", "win");
                }
                else {
                    window.open("../Common/ExcelExport.aspx?Random=" + Math.random() + "&TransFlg=RecuperatePlanSumirise" + "&Action=SELECT", "win");
                }

            });


            /////////////////////////////////////////////////画面事件//////////////////////////////////////////////


        });
	
    </script>

    <!-- END    画面的控制  END   -->
</head>
<body>
    <form id="mainForm" runat="server">
    <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <table width="99%" cellpadding="0" cellspacing="0" class="table">
                    <tr>
                        <td valign="top">
                            <table width="100%" class="top" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td style="height: 22px;">
                                        &nbsp;<b>当前位置:</b>&nbsp;<a href="#">职工福利</a>&nbsp;>>&nbsp;<a href="#">员工疗(休)养计划表</a><input
                                            id="txtRowNo" type="text" style="display: none" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px">
                        </td>
                    </tr>
                    <tr>
                        <td align="right" valign="middle" style="border: thin dotted #C0C0C0; background-color: #C5E5FC">
                            <img alt="" id="btnNew" src="../images/button/btnOpenAdd.gif" />
                            &nbsp;
                            <img alt="" id="btnOpen" src="../images/button/btnOpen.gif" />
                            &nbsp;
                            <img alt="" id="btnSave" src="../images/button/btnSave.gif" />
                            &nbsp;
                            <img alt="" id="btnPrintView" src="../images/button/btnPrint.gif" />
                            <!--&nbsp;
                            <img alt="" id="btnPrint" src="../images/button/btnPrintSet.gif" />-->
                            &nbsp;
                            <img alt="" id="btnDelete" src="../images/button/btnDeleteRow.gif" />
                            &nbsp;
                            <img alt="" id="btnEdit" src="../images/button/btnEditRow.gif" />
                            &nbsp;
                            <img alt="" id="btnExcelExport" src="../images/button/btnExcelExport.gif" />
                            <%--&nbsp;
                            <img alt="" id="btnSummarys" src="../images/button/btnSummary.gif" />--%>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px">
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 30px" align="center" class="style1">
                            <span id="spBegin"></span>年—<span id="spEnd"></span>年度职员工疗（休）养计划表
                            <br />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div style="float: left; margin-left: 2px">
                                单位：<asp:Label ID="lblUnion" runat="server" /><input id="Hidden1" type="hidden" runat="server" />
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top">
                            <table id='example' style="width: 100%; border-collapse: collapse;">
                                <!--<thead style="text-align:center;" >-->
                                <tr>
                                    <th style="width: 40px; height: 22px; background-color: #B2DBF7;" align="center">
                                        序号
                                    </th>
                                    <th style="height: 22px; background-color: #B2DBF7;" align="center">
                                        单位名称
                                    </th>
                                    <th style="width: 120px; height: 44px; background-color: #B2DBF7;" align="center">
                                        应享受职工数
                                    </th>
                                    <th style="width: 80px; height: 22px; background-color: #B2DBF7;" align="center">
                                        <span id="Span1"></span>年计划
                                    </th>
                                    <th style="width: 80px; height: 22px; background-color: #B2DBF7;" align="center">
                                        <span id="Span2"></span>年计划
                                    </th>
                                    <th style="width: 80px; height: 22px; background-color: #B2DBF7;" align="center">
                                        <span id="Span3"></span>年计划
                                    </th>
                                    <th style="width: 80px; height: 22px; background-color: #B2DBF7;" align="center">
                                        <span id="Span4"></span>年计划
                                    </th>
                                    <th style="width: 80px; height: 22px; background-color: #B2DBF7;" align="center">
                                        <span id="Span5"></span>年计划
                                    </th>
                                    <th style="height: 22px; background-color: #B2DBF7; display: none" align="center">
                                        单位ID
                                    </th>
                                </tr>
                                <!--</thead>-->
                                <!--<tbody id='content'>-->
                                <!--</tbody>-->
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <asp:HiddenField ID="hddUnionID" runat="server" />
    <asp:HiddenField ID="hddRights" runat="server" />
    <asp:HiddenField ID="hddSumarry" runat="server" />
    <asp:HiddenField ID="hddOpen" runat="server" />
    <asp:HiddenField ID="hddYear" runat="server" />
    <div id="datepanle" title="开始年份">
        <fieldset>
            <div style="text-align: center; vertical-align: middle">
                <input id="txtDate" type="text" maxlength="4" />年&nbsp;<font color="red">*为四位数字</font></div>
        </fieldset>
    </div>

    <script type="text/javascript">
        $("#datepanle").hide();
    </script>

    </form>
</body>
</html>
